import { RouterView } from 'vue-router'
import router from '@/router/index.js'

// 刷新
const RefreshRoute = {
  path: '/refresh',
  name: 'Refresh',
  component: RouterView,
  meta: {
    title: 'route.refresh',
  },
  beforeEnter: (to, from) => {
    // 刷新
    setTimeout(() => {
      router.replace(from.fullPath)
    })
    return true
  },
}

// 跟路由 静态路由
/**
 * meta 属性
 * title: 路由标题
 * icon: 路由图标
 * namePath： 路由名称路径（当前路由namePath 祖先name集合）
 * outsideLink：是否外链 (window.open) 起一个新标签页
 * iframe：iframe内嵌
 * */
const RootRoute = {
  path: '/',
  redirect: '/dashboard/listOfGames',
  name: 'Layout',
  component: () => import('@/layouts/LayoutDefault.vue'),
  meta: {
    title: 'route.rootRoute',
    icon: 'material-symbols:account-tree-outline-rounded',
  },
  children: [
    {
      path: '/dashboard',
      redirect: '/dashboard',
      name: 'Dashboard',
      meta: {
        title: 'route.dashboard',
        icon: 'lineicons:control-panel',
        namePath: ['Dashboard'],
      },
      children: [
        {
          path: 'createAGame',
          name: 'createAGame',
          component: () =>
            import('@/views/example/workbench/createAGame.vue'),
          meta: {
            title: 'route.createAGame',
            // icon: 'icon-park-outline:workbench',
            icon: 'material-symbols:create-new-folder-outline',
            namePath: ['Dashboard', 'createAGame'],
          },
        },
        {
          path: "concurrentNetwork",
          name: "concurrentNetwork",
          component: () => import("@/views/example/concurrentNetwork/indexView.vue"),
          meta: {
            title: "route.concurrentNetwork",
            icon: 'material-symbols:apk-install-outline',
            namePath: ['Dashboard', 'concurrentNetwork'],
          },
        },
        {
          path: "listOfGames",
          name: "listOfGames",
          component: () => import("@/views/example/listOfGames/indexView.vue"),
          meta: {
            title: "route.listOfGames",
            icon: 'teenyicons:game-controller-retro-outline',
            namePath: ['Dashboard', 'concurrentNetwork'],
            requireAuth: true, // 判断是否需要登录
          },
        },
        {
          path: "gameUpdate",
          name: "gameUpdate",
          component: () => import("@/views/example/listOfGames/gameUpdateView.vue"),
          meta: {
            title: "route.gameUpdate",
            icon: 'icon-park-outline:workbench',
            namePath: ['Dashboard', 'gameUpdate'],
          },
        },
        {
          path: "details",
          name: "details",
          // hidden: true,
          component: () => import("@/views/example/details/indexView.vue"),
          meta: {
            title: "route.details",
            icon: 'fluent-mdl2:activate-orders',
            namePath: ['Dashboard', 'details'],
          },
        },
        {
          path: "historicalRecord",
          name: "historicalRecord",
          // hidden: true,
          component: () => import("@/views/example/historicalRecord/historyView.vue"),
          meta: {
            title: "route.historicalRecord",
            icon: 'icon-park-outline:history-query',
            namePath: ['Dashboard', 'historicalRecord'],
          },
        },
        {
          path: "auditProcedure",
          name: "auditProcedure",
          component: () => import("@/views/example/auditProcedure/indexView.vue"),
          meta: {
            title: "route.auditProcedure",
            icon: 'icon-park-outline:workbench',
            namePath: ['Dashboard', 'details'],
          },
        },
      ],
    },
    {
      path: '/realTimeData',
      redirect: '/realTimeData/customModel',
      name: 'RealTimeData',
      meta: {
        title: 'route.realTimeData',
        icon: 'icon-park-outline:chart-histogram',
        namePath: ['RealTimeData'],
      },
      children: [
        {
          path: 'customModel',
          name: 'customModel',
          component: () =>
            import('@/views/customModel/indexView.vue'),
          meta: {
            title: 'route.customModel',
            icon: 'icon-park-outline:workbench',
            namePath: ['RealTimeData', 'customModel'],
          },
        },
        {
          path: "test",
          name: "test",
          component: () => import("@/views/test/indexView.vue"),
          meta: {
            title: "route.test",
            icon: 'icon-park-outline:workbench',
            namePath: ['RealTimeData', 'test'],
          },
        },
        {
          path: "aggregateData",
          name: "aggregateData",
          component: () => import("@/views/aggregateData/indexView.vue"),
          meta: {
            title: "route.aggregateData",
            icon: 'icon-park-outline:workbench',
            namePath: ['RealTimeData', 'aggregateData'],
          },
        },
      ],
    },
    {
      path: '/MessageCenter',
      redirect: '/MessageCenter/MessageCenter',
      name: 'MessageCenter',
      meta: {
        title: 'route.MessageCenter',
        icon: 'tabler:message-2-minus',
        namePath: ['MessageCenter'],
      },
      children: [
        {
          path: 'MessageList',
          name: 'MessageList',
          component: () =>
            import('@/views/MessageList/indexView.vue'),
          meta: {
            title: 'route.MessageList',
            icon: 'icon-park-outline:workbench',
            namePath: ['MessageCenter', 'MessageList'],
          },
        },
        {
          path: 'ProblemFedback',
          name: 'ProblemFedback',
          component: () =>
            import('@/views/ProblemFedback/indexView.vue'),
          meta: {
            title: 'route.ProblemFedback',
            icon: 'icon-park-outline:workbench',
            namePath: ['MessageCenter', 'ProblemFedback'],
          },
        },
      ],
    },
    {
      path: '/developerServices',
      redirect: '/developerServices/developerAccount',
      name: 'DeveloperServices',
      meta: {
        title: 'route.developerServices',
        icon: 'material-symbols:dashboard-outline',
        namePath: ['DeveloperServices'],
      },
      children: [
        {
          path: 'developerAccount',
          name: 'developerAccount',
          component: () =>
            import('@/views/developerAccount/AccountView.vue'),
          meta: {
            title: 'route.developerAccount',
            icon: 'icon-park-outline:workbench',
            namePath: ['DeveloperServices', 'developerAccount'],
          },
        },
        {
          path: 'developerAccountEdit',
          name: 'developerAccountEdit',
          hidden: true,
          component: () =>
            import('@/views/developerAccountEdit/AccountEdit.vue'),
          meta: {
            title: 'route.developerAccountEdit',
            icon: 'material-symbols:dashboard-outline',
            namePath: ['DeveloperServices', 'developerAccountEdit'],
          },
        },
        {
          path: 'changeTheTel/:switchingType',
          name: 'changeTheTel',
          hidden: true,
          component: () =>
            import('@/views/changeTheTel/changeTheTel.vue'),
          meta: {
            title: 'route.changeTheTel',
            icon: 'material-symbols:dashboard-outline',
            namePath: ['DeveloperServices', 'changeTheTel'],
          },
        },
        {
          path: 'customerServiceHelp',
          name: 'customerServiceHelp',
          component: () =>
            import('@/views/customerServiceHelp/ServiceHelp.vue'),
          meta: {
            title: 'route.customerServiceHelp',
            icon: 'lsicon:service-filled',
            namePath: ['DeveloperServices', 'customerServiceHelp'],
          },
        },
        {
          path: 'cancelAccount',
          name: 'cancelAccount',
          hidden: true,
          component: () =>
            import('@/views/cancelAccount/cancelAccount.vue'),
          meta: {
            title: 'route.cancelAccount',
            icon: 'material-symbols:dashboard-outline',
            namePath: ['DeveloperServices', 'cancelAccount'],
          },
        },
        {
          path: 'demo',
          name: 'demo',
          component: () =>
            import('@/views/demo/demoView.vue'),
          meta: {
            title: 'route.demo',
            icon: 'material-symbols:dashboard-outline',
            namePath: ['DeveloperServices', 'demo'],
          },
        },
      ],
    },
    {
      path: '/outside',
      redirect: '/outside/iframe',
      name: 'OutSide',
      meta: {
        title: 'route.outsidePage',
        icon: 'material-symbols:link',
        namePath: ['OutSide'],
      },
      children: [
        {
          path: 'iframe',
          name: 'Iframe',
          component: () => import('@/views/iframe/IframeView.vue'),
          meta: {
            title: 'route.bilibili',
            icon: 'oui:nested',
            namePath: ['OutSide', 'Iframe'],
            // iframe: 'https://www.bilibili.com/', // 内嵌
            iframe: 'http://192.168.3.152:8083/login', // 内嵌
            // iframe: 'https://admin2.100520.com/login', // 内嵌
          },
        },
        {
          path: 'https://www.zhihu.com/', // 外链
          name: 'OutsideLink',
          meta: {
            title: 'route.zhihu',
            icon: 'icon-park-outline:stereo-nesting',
            namePath: ['OutSide', 'OutsideLink'],
            outsideLink: true,
          },
        },
      ],
    },
    {
      path: '/about',
      name: 'About',
      component: () => import('@/views/example/about/AboutView.vue'),
      meta: {
        title: 'route.about',
        icon: 'material-symbols:info-outline-rounded',
        namePath: ['About'],
      },
    },
    RefreshRoute,
  ],
}

export default RootRoute
